﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script type="text/javascript">
    var keyValue = $.request("keyValue");
    $(function () {
        getItemList();
        $("#F_Companions").select2({ multiple: true });
        if (keyValue != null) {
            getEntity();
        }
    });

    function getEntity() {
        $.ajax({
            url: "/MyTask/MySalesReport/GetEntity?keyValue=" + keyValue,
            dataType: "json",
            async: false,
            success: function (data) {                
                $("#form1").formSerialize(data);
                $("#F_Companions").val(data.F_Companions.split(',')).trigger('change');  
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }

    function getItemList() {
        $.ajax({
            url: "/MyTask/MySalesReport/GetItemListJson",
            dataType: "json",
            async: false,
            success: function (data) {
                initControl(data)
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }

    function submitForm() {
        //if (!$('#form1').formValid()) {
        //    return false;
        //}
        //var params = $("#form1").formSerialize();
        //$.submitForm({
        //    url: "/MyTask/MySalesReport/SubmitForm?keyValue=" + keyValue,
        //    param: params,
        //    success: function () {
        //        $.currentWindow().$("#gridList").trigger("reloadGrid");
        //    }
        //})
    }

    function initControl(data) {
        var citys = data.citys;
        for (var i = 0; i < citys.length; i++) {
            $("#F_CityId").append("<option value='" + citys[i].F_ItemCode + "'>" + citys[i].F_ItemName + "</option>");
        }

        var activityType = data.activityType;
        for (var i = 0; i < activityType.length; i++) {
            $("#F_ActivityType").append("<option value='" + activityType[i].F_ItemCode + "'>" + activityType[i].F_ItemName + "</option>");
        }

        var sshy = data.sshy;
        for (var i = 0; i < sshy.length; i++) {
            $("#F_ActivityIndustry").append("<option value='" + sshy[i].F_ItemCode + "'>" + sshy[i].F_ItemName + "</option>");
        }

        var SiteType = data.SiteType;
        for (var i = 0; i < SiteType.length; i++) {
            $("#F_SiteType").append("<option value='" + SiteType[i].F_ItemCode + "'>" + SiteType[i].F_ItemName + "</option>");
        }

        var hdjd = data.hdjd;
        for (var i = 0; i < hdjd.length; i++) {
            $("#F_ActivityStep").append("<option value='" + hdjd[i].F_ItemCode + "'>" + hdjd[i].F_ItemName + "</option>");
        }

        var SiteSupportingFacilities = data.SiteSupportingFacilities;
        for (var i = 0; i < SiteSupportingFacilities.length; i++) {
            $("#F_Companions").append("<option value='" + SiteSupportingFacilities[i].F_ItemCode + "'>" + SiteSupportingFacilities[i].F_ItemName + "</option>");
        }

        var clients = data.clients;
        for (var i = 0; i < clients.length; i++) {
            $("#F_ClientId").append("<option value='" + clients[i].F_Id + "'>" + clients[i].F_ClientName + "</option>");
        }
    }
</script>
<form id="form1">
    <div style="padding-top: 20px;">
        <table id="form1" class="form" style="margin-top:3px;">
            <tr>
                <td colspan="6" class="interval">活动信息</td>
            </tr>
            <tr>
                <td class="formTitle">客户名称</td>
                <td class="formValue">
                    <select id="F_ClientId" name="F_ClientId" class="form-control required" disabled="disabled">
                        <option value="">==请选择客户名称==</option>
                    </select>
                </td>
                <td class="formTitle">活动名称</td>
                <td class="formValue">
                    <input id="F_ActivityName" name="F_ActivityName" type="text" class="form-control" placeholder="活动名称" disabled="disabled" />
                </td>
                <td class="formTitle">活动城市</td>
                <td class="formValue">
                    <select id="F_CityId" name="F_CityId" class="form-control required" disabled="disabled">
                        <option value="">==请选择活动城市==</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="formTitle">活动所属行业</td>
                <td class="formValue">
                    <select id="F_ActivityIndustry" name="F_ActivityIndustry" class="form-control required" disabled="disabled">
                        <option value="">==请选择活动所属行业==</option>
                    </select>
                </td>
                <td class="formTitle">活动类型</td>
                <td class="formValue">
                    <select id="F_ActivityType" name="F_ActivityType" class="form-control required" disabled="disabled">
                        <option value="">==请选择活动类型==</option>
                    </select>
                </td>
                <td class="formTitle">预算金额</td>
                <td class="formValue">
                    <input id="F_BudgetCash" name="F_BudgetCash" type="text" class="form-control" placeholder="预算金额" disabled="disabled" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">活动阶段</td>
                <td class="formValue">
                    <select id="F_ActivityStep" name="F_ActivityStep" class="form-control required" disabled="disabled">
                        <option value="">==请选择活动阶段==</option>
                    </select>
                </td>
                <td class="formTitle">品牌</td>
                <td class="formValue">
                    <input id="F_Brand" name="F_Brand" type="text" class="form-control" placeholder="品牌" disabled="disabled" />
                </td>
                <td class="formTitle"></td>
                <td class="formValue"></td>
            </tr>
            <tr>
                <td colspan="6" class="interval">场地需求</td>
            </tr>
            <tr>
                <td class="formTitle">场地类型</td>
                <td class="formValue">
                    <select id="F_SiteType" name="F_SiteType" class="form-control required" disabled="disabled">
                        <option value="">==请选择场地类型==</option>
                    </select>
                </td>
                <td class="formTitle">场地大小</td>
                <td class="formValue">
                    <input id="F_SiteSize" name="F_SiteSize" type="text" class="form-control" placeholder="场地大小" disabled="disabled" />
                </td>
                <td class="formTitle">预计人数</td>
                <td class="formValue">
                    <input id="F_PeopleNum" name="F_PeopleNum" type="text" class="form-control" placeholder="预计人数" disabled="disabled" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">配套服务</td>
                <td class="formValue" colspan="5">
                    <select id="F_Companions" name="F_Companions" class="form-control required" disabled="disabled">
                        <option value="">==请选择配套服务==</option>
                    </select>
                </td>               
            </tr>
        </table>
    </div>
</form>